<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <include file="./Application/Admin/View/block/amap_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/Public/uploadfy/uploadify.css" />
    <script type="text/javascript" src="/Public/uploadfy/jquery.uploadify.min.js"></script>
    <style>
        #dg{
            height: 100%;
        }
        #tabs_pumpstation table{
            line-height: 30px;
        }
        a{
            text-decoration: none;
            font-size: 14px;
            color: #000000;
        }
        .ul{
            list-style: none;
            float: left;
        }
        .ul li{
            float: left;
            width: 112px;
            padding: 6px;
            text-align: center;
        }
        .ul li img{
            width: 100px;
            height: 150px;
        }
    </style>
    <script>
        function switchPumpStation(id) {
            reset_img();
            $('#pumpstation_id').val(id);
            $('.ps_id_hidden').val(id);
            //清空所有form
            $('form').form('clear');
            $("input[name='pumpid']").val(id);
            editPumpstation($('#pumpstation_id').val());
            $('#fy_just_see_panel').panel('refresh','__URL__/fy_just_see?ps_id='+id);
        }

        function reset_img(){
//            $('#ps_plan_img').attr('src', '__PUBLIC__/img/no_pic.jpg');
//            $('#ps_plans_img').attr('src', '__PUBLIC__/img/no_pic.jpg');
//            $('#ps_img_img').attr('src', '__PUBLIC__/img/no_pic.jpg');
            $('#s_1_div').empty();
            $('#s_2_div').empty();
            $('#s_3_div').empty();
        }

        function get_s_id(){
            return $('#pumpstation_id').val();
        }

    </script>
</block>
<block name="bdoy">
    <body>
        <table id="dg"></table>
        <div id="toolbar" style="padding:5px;height:auto">
            <div style="margin-bottom:5px">
                <?php if(!I('get.justsee')){?>
                <a href="#" id="add_button" class="easyui-linkbutton" iconCls="icon-add" plain="true">新增</a>
                <a href="#" id="edit_button" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑</a>
                <a href="#" id="del_button" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
                <?php }?>
                <a href="#" id="search_button" class="easyui-linkbutton" iconCls="icon-search" plain="true">高级{:LANG('search')}</a>
                <?php if(!I('get.justsee')){?>
                <a href="#" id="reload_button" class="easyui-linkbutton" iconCls="icon-reload" plain="true">重载</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon_ext icon-import" plain="true" onclick="open_dialog('/Manage/Admin/open_window_import?url=__URL__/import')">导入</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon_ext icon-rescueLog" plain="true" onclick="open_tab('__URL__/export')">导出</a>
                <?php }?>
                <?php if(I('get.justsee')){?>
                <a href="#" id="edit_button" class="easyui-linkbutton" iconCls="icon-edit" plain="true">查看</a>
                <?php }?>
                <form id="query_form_base_info" method="post" action="">
                    <table>
                        <tr>
                            <td>泵站类型</td>
                            <td>
                                <select id="pump_station_cat_1" style="width:120px;" name="ps_catg1">
                                    {:pump_station_types_option()}
                                </select>
                            </td>
                            <td>泵站名称</td>
                            <td>
                                <input id="pump_station" name="ps_name"/>
                            </td>

                            <td><a id="query_button_base_info" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                            <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form_base_info').form('clear');">重置</a></td>
                        </tr>
                    </table>
                </form>
                <!--            <a href="#" id="clear_button" class="easyui-linkbutton" iconCls="icon-redo" plain="true">{:LANG('clearSelections')}</a>-->
            </div>
            <div id="queryMaterialsRemovalParamZone">
                <fieldset>
                    <legend>属性搜索</legend>
                    <form id="query_form" method="post" action="">
                        <table>
                            <tr>
                                <td>表名</td>
                                <td>
                                    <select id="table_index" style="width:120px;">
                                        <option></option>
                                        <option value="base">基本信息</option>
                                        <option value="ps_status">设施状态</option>
                                        <option value="belong_info">权属信息</option>
                                        <option value="device">配套设备</option>
                                        <option value="data">数据信息</option>
                                    </select>
                                </td>
                                <td>字段</td>
                                <td id="table_field">
                                    <input class="easyui-combobox"/>
                                </td>
                                <td>查询条件</td>
                                <td id="condition_td">
                                    <input type="text"/>
                                </td>

                                <td><a id="query_button" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                                <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form').form('clear');">重置</a></td>
                            </tr>
                        </table>
                    </form>
                </fieldset>
                <fieldset>
                    <legend>高级搜索</legend>
                    <form id="query_form_gen" method="post" action="">
                        <table>
                            <tr>
                                <td>运行情况</td>
                                <td>
                                    <select name="status" data-options="prompt:'{:LANG('pls_input')}',required:true" style="width: 80px;">
                                        {:station_status_option()}
                                    </select>
                                </td>
                                <td><a id="query_button_gen" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                                <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form_gen').form('clear');">重置</a></td>
                            </tr>
                        </table>

                    </form>
                </fieldset>
            </div>
        </div>
    <div id="listDialog" class="easyui-dialog" title="泵站信息" closed="true" fit="true" resizable='false' modal="true" minimizable="false" collapsible="false">
        <input type="hidden" id="pumpstation_id" name="pumpstation_id"/>
        <div class="easyui-tabs" id="tabCtrl" fit="true" border="false">
            <div title="泵站基础信息" id="subTabCtrl_1" fit=true  closable="false" style="padding:10px;" href="__URL__/base_info?justsee={:I('get.justsee')}" loadingMessage="{:LANG('loading')}">

            </div>
            <?php if(I('get.justsee')){?>
            <div title="设备查看" id="fy_just_see_panel" fit=true  closable="false" style="padding:10px;" loadingMessage="{:LANG('loading')}">
            </div>
            <?php }?>
            <?php if(!I('get.justsee')){?>
            <div title="雨情记录" closable="false"  style="padding:10px;" href="__URL__/weather_log" loadingMessage="{:LANG('loading')}" fit="true">

            </div>
            <?php }?>
        </div>
    </div>
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        $(function(){
//            document.getElementById('fy_just_see').contentWindow.location.reload(true);
            $("#pump_station_cat_1").change(function(){
                $('#pump_station').combobox('clear');
                $('#pump_station').combobox('reload','/Manage/AdminPumpStation/get_all_combox_with_catg1?ps_catg1='+$(this).val());
            });
            $('#pump_station').combobox({
                url:'/Manage/AdminPumpStation/get_all_combox',
                valueField:'name',
                textField:'name',
                width:180,
            });
            var request_url = '__URL__/get_all';
            var add_title = '新增';
            var edit_title = '编辑';
            jQuery('#dg').datagrid({
                fit:true,
                nowrap: false,
                striped: true,
                collapsible:false,
                showFooter: true,
                url:request_url,
                method:'get',
                pageNumber:1,
                pageSize:20,
                pageList:[20,50,100,200],
                idField:'id',
                remoteSort: true,
                sortOrder:'desc',
                columns:[[
                    {field:'ck',title:'', width:80,checkbox:true,align:'center'},
                    {field:'id',title:'ID', width:80,align:'center',hidden:true},
                    {field:'ps_name',title:'泵站名称', width:180,align:'center',sortable:true},
                    {field:'charge_person',title:'执勤人员', width:180,align:'center',sortable:true},
                    {field:'ps_id',title:'排水泵站标识码', width:120,align:'center',sortable:true},
                    {field:'status',title:'运行情况', width:80,align:'center',sortable:true},
                    {field:'ps_catg1',title:'泵站大类', width:80,align:'center',sortable:true},
                    {field:'ps_scale',title:'泵站规模', width:80,align:'center',sortable:true},
                    {field:'ps_region',title:'行政区划', width:80,align:'center',sortable:true},
                    {field:'ps_sts',title:'设施状态', width:80,align:'center',sortable:true},
                    {field:'ps_run_typ',title:'运转类型', width:80,align:'center',sortable:true},
                    {field:'ps_guard_typ',title:'值守类型', width:80,align:'center',sortable:true},
                    {field:'ps_w_purific',title:'下游水质净化厂', width:150,align:'center',sortable:true},
                    {field:'ps_to_riv',title:'排入水体', width:150,align:'center',sortable:true},
                    {field:'ps_p_num',title:'总水泵台数', width:80,align:'center',sortable:true},
                    {field:'ps_bkp_num',title:'备用水泵台数', width:80,align:'center',sortable:true},
                    {field:'ps_drain_amt',title:'总排水能力<br>(立方米/时)', width:100,align:'center',sortable:true},
                    {field:'ps_dev_cap',title:'总装机容量<br>(千瓦)', width:100,align:'center',sortable:true},
                    {field:'ps_power_amt',title:'泵站总功率<br>(千瓦)', width:80,align:'center',sortable:true},
                    {field:'ps_rwp_num',title:'雨水泵台数', width:80,align:'center',sortable:true},
                    {field:'ps_rwdrain_amt',title:'雨水总排水能力<br>(立方米/时)', width:100,align:'center',sortable:true},
                    {field:'ps_sp_num',title:'污水泵台数', width:80,align:'center',sortable:true},
                    {field:'ps_sdrain_amt',title:'污水总排水能力<br>(立方米/时)', width:100,align:'center',sortable:true},
                    {field:'ps_elev',title:'地面高程<br>(米)', width:80,align:'center',sortable:true},
                    {field:'ps_svc_scope',title:'服务范围', width:150,align:'center',sortable:true},
                ]],
                pagination:true,
                rownumbers:true,
                singleSelect:false,
                toolbar: '#toolbar',
                onDblClickRow: function(rowIndex, rowData) {
                    switchPumpStation(rowData.id);
                    $('#listDialog').dialog({title:rowData.ps_name,modal:true});
                    $('#listDialog').dialog('open');
                    $('#listDialog').dialog('maximize');
                    $('#tabs_pumpstation').tabs({height:$('#subTabCtrl_1').height(),width:$('#subTabCtrl_1').width()-20});
                },
            });
            //按钮事件绑定
            $('#add_button').click(function(){
                addPumpstation();
                reset_img();
                $('#pumpstation_id').val('');
                $('#listDialog').dialog({modal:true});
                $('#listDialog').dialog('open');
                $('#listDialog').dialog('maximize');
                $('#tabs_pumpstation').tabs({height:$('#subTabCtrl_1').height(),width:$('#subTabCtrl_1').width()-20});

            });
            $('#edit_button').click(function(){
                var rows = $('#dg').datagrid('getSelections');
                if(rows.length > 1){
                    $.messager.alert('提示','当前选择了多条信息，不可以操作！','error');
                    return;
                }
                var obj = jQuery('#dg').datagrid('getSelected');
                if(!obj){
                    msgShow('{:LANG('tips')}', '{:LANG('pls_slet_row')}', 'warning');
                }
                switchPumpStation(obj.id);
                $('#listDialog').dialog({title:obj.ps_name,modal:true});
                $('#listDialog').dialog('open');
                $('#listDialog').dialog('maximize');
                $('#tabs_pumpstation').tabs({height:$('#subTabCtrl_1').height(),width:$('#subTabCtrl_1').width()-20});

            });
            $('#del_button').click(function(){
                var ids = [];
                var rows = $('#dg').datagrid('getSelections');
                for ( var i = 0; i < rows.length; i++) {
                    ids.push(rows[i].id);
                }
                jQuery.messager.confirm('请确认', '你确定要删除吗？', function(r){
                    if (r){
                        $.ajax({
                            url:"__URL__/deleteArray",
                            data:{"ids":ids.join(',')},
                            method: "post",
                            dataType: "json",
                            async: true,
                            success: function(data) {
                                if (data.status==1) {
                                    $('#pumpstation_id').val('');
                                    $('#dg').datagrid('reload');
                                    $('#dg').datagrid("unselectAll");
                                    $.messager.show({title:'提示',msg:'删除成功！',showType:'slide'});
                                }
                                else $.messager.alert('提示','删除失败！','error');
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                $.messager.alert('提示','删除出错，错误类型为!'+textStatus,'error');
                            }
                        });
                    }
                });
            });
            $('#search_button').click(function(){
                $('#queryMaterialsRemovalParamZone').toggle();
                $('#dg').datagrid("resize");
            });
            $('#reload_button').click(function(){
                $('#dg').datagrid('load', {});
            });
            $('#reload_clear').click(function(){
                $('#dg').datagrid('clearSelections');
            });

            $('#query_button').click(function(){
                var obj = $('#query_form').serializeJson();
                $('#dg').datagrid('load',obj);
            });
            $('#query_button_base_info').click(function(){
                var obj = $('#query_form_base_info').serializeJson();
                $('#dg').datagrid('load',obj);
            });
            $('#query_button_gen').click(function() {
                var obj = $('#query_form_gen').serializeJson();
                obj['gen'] = '1';
                $('#dg').datagrid('load',obj);
            });
            $('#table_index').change(function(){
                var model = 'PumpingStation';
                table_index_change(model, $(this).val());
            });
            $('#queryMaterialsRemovalParamZone').hide();
        });


    </script>
</block>
